package com.example.computer_exam_training_sys.mapper;

import com.example.computer_exam_training_sys.entity.User_Schedules_Entity;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface User_Schedules_Mapper {
    // 查询所有
    @Select("SELECT * FROM user_schedules")
    List<User_Schedules_Entity> selectAll();

    // 按userId条件查询
    @Select("SELECT * FROM user_schedules WHERE user_id = #{userId}")
    List<User_Schedules_Entity> selectByUserId(@Param("userId") Integer userId);

    // 新增
    @Insert("INSERT INTO user_schedules (user_id, content, schedule_date, start_time, end_time, is_completed, create_time) VALUES (#{userId}, #{content}, #{scheduleDate}, #{startTime}, #{endTime}, #{isCompleted}, #{createTime})")
    int insert(User_Schedules_Entity entity);

    // 更新
    @Update("UPDATE user_schedules SET content=#{content}, schedule_date=#{scheduleDate}, start_time=#{startTime}, end_time=#{endTime}, is_completed=#{isCompleted} WHERE schedule_id=#{scheduleId}")
    int update(User_Schedules_Entity entity);

    // 删除
    @Delete("DELETE FROM user_schedules WHERE schedule_id=#{scheduleId}")
    int delete(@Param("scheduleId") Integer scheduleId);
}
